package com.example.module.dialog;

import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.widget.EditText;

public class PasscodeText extends EditText {
	private PasscodeTextWatcher textDelegate;

	public PasscodeText(Context context, AttributeSet attrs) {
		super(context, attrs);
	}
	
	public void setPasscodeTextWatcher(PasscodeTextWatcher textDelegate) {
		this.textDelegate = textDelegate;
		addTextChangedListener(textDelegate);
	}
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (textDelegate != null)
			textDelegate.onKeyDown(this.getText(), keyCode, event);
		
		return super.onKeyDown(keyCode, event);
	}
}
